<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('用户列表')"/>
    <th:block th:include="include :: layout-latest-css"/>
    <th:block th:include="include :: ztree-css"/>
</head>
<body class="gray-bg">

<div class="ui-layout-west">
    <div class="box box-main">
        <div class="box-header">
            <div class="box-title">
                <i class="fa icon-grid"></i> 表单列表
            </div>
        </div>

        <div class="ui-layout-content">
            <div id="tree" class="ztree"></div>
        </div>
    </div>
</div>

<div class="ui-layout-center">
    <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="user-form">
                    <input type="hidden" id="id" name="id">
                    <input type="hidden" id="progressId" name="progressId" value="2">
                </form>
            </div>
            <P>[[${id}]]</P>

            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
</div>

<th:block th:include="include :: footer"/>
<th:block th:include="include :: layout-latest-js"/>
<th:block th:include="include :: ztree-js"/>
<script th:inline="javascript">
    var prefix = ctx + "system/user";

    $(function () {
        var panehHidden = false;
        if ($(this).width() < 769) {
            panehHidden = true;
        }
        $('body').layout({initClosed: panehHidden, west__size: 185});
        // 回到顶部绑定
        if ($.fn.toTop !== undefined) {
            var opt = {
                win: $('.ui-layout-center'),
                doc: $('.ui-layout-center')
            };
            $('#scroll-up').toTop(opt);
        }
        queryTemplate();
        queryWorkListTree();
    });

    function queryTemplate() {
        var templateId = $("#id").val();
        var progressId = $("#progressId").val();
        console.log("templateId:" + templateId );
        console.log("progressId:" + progressId );
    }

    function queryWorkListTree() {
        var progressId = $('#progressId').val();
        console.log(progressId);
        var url = ctx + "work/progress/treeData/" + progressId;
        var options = {
            url: url,
            expandLevel: 1,
            onClick: zOnClick
        };
        $.tree.init(options);

        function zOnClick(event, treeId, treeNode) {
            $("#id").val(treeNode.id);

            console.log(treeNode);

            console.log("templateId:" + $("#id").val() );
            console.log("progressId:" + $("#progressId").val());
            //重新加载本界面
            //http://localhost:8088/work/templatetable7/view/15
            var url = ctx + "work/templatetable7/view/" + $("#id").val();
            $.modal.parentTab('任务填报', url)
            // console.log(url);
        }
    }

</script>
</body>

</html>